/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.gameserver.model.entity.eventengine;

import java.util.HashMap;
import java.util.Map;

import net.sf.l2j.gameserver.model.entity.eventengine.events.DeathMatch;

/**
 * @author Anarchy
 *
 */
public class EventManager
{
	private boolean _eventActive = false;
	private AbstractEvent _event = null;
	private Map<String, AbstractEvent> _events = new HashMap<String, AbstractEvent>();
	
	public static EventManager getInstance()
	{
		return SingletonHolder._instance;
	}
	
	private EventManager()
	{
		addEventToList(new DeathMatch());
	}
	
	public boolean addEventToList(AbstractEvent event)
	{
		String eventName = event.getName();
		
		if (eventName == null)
		{
			return false;
		}
		if (_events.keySet().contains(eventName))
		{
			return false;
		}
		
		return _events.put(eventName, event) != null;
	}
	
	public boolean isEventActive()
	{
		return _eventActive;
	}
	
	public void setEventActive(boolean val)
	{
		_eventActive = val;
	}
	
	public AbstractEvent getActiveEvent()
	{
		return _event;
	}
	
	public void setActiveEvent(AbstractEvent val)
	{
		_event = val;
	}
	
	private static class SingletonHolder
	{
		protected static final EventManager _instance = new EventManager();
	}
}
